package com.eshop.we.mapper;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.eshop.we.suggest.dto.SuggestDto;
import com.eshop.we.suggest.entity.Suggest;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;

@Mapper
@Component
public interface SuggestMapper extends BaseMapper<Suggest> {

    @Select("<script>" +
            " select s.*,u.real_name as name ,u.mobile  " +
            " from suggest s " +
            " left join user u on s.user_id= u.id " +
            " where 1=1 "+
            " <if test='name!=null '>"+
            " and u.real_name like     CONCAT(CONCAT('%', #{name}), '%') "+
            " </if>"+
            "<if test='mobile!=null '>"+
            " and u.mobile like  CONCAT(CONCAT('%', #{mobile}), '%')"+
            " </if>"+
            " <if test='start!=null '>"+
            " and s.ctime &gt;=  #{start} "+
            " </if>"+
            " <if test='end!=null '>"+
            " and s.ctime &lt;=  #{end} "+
            " </if> "+
            " </script>")
    List<SuggestDto> selectSuggestPage(Page<SuggestDto> page, @Param("name") String  name, @Param("mobile")String mobile, @Param("start")Long start,@Param("end") Long end);
}
